package org.amj.wn;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.amj.wn.SchemaItem.UIOptions;

public enum Property {

	PAGE_1(UIElement.PAGE, "Page 1", null),
	SECTION_1(UIElement.SECTION, "Personal Information", null),
	passCode(UIElement.FIELD, "Passcode", UIOptions.hidden),
	memberCode(UIElement.FIELD, "Member Code", UIOptions.label),
	firstName(UIElement.FIELD, "First Name", UIOptions.text),
	lastName(UIElement.FIELD, "Last Name", UIOptions.text),
	gender(UIElement.FIELD, "Gender", UIOptions.combo, "Male", "Female"),
	SECTION_2(UIElement.SECTION, "Address", null),
	houseNumber(UIElement.FIELD, "House Number", UIOptions.text),
	street(UIElement.FIELD, "Street", UIOptions.text),
	city(UIElement.FIELD, "City", UIOptions.text),
	province(UIElement.FIELD, "Province", UIOptions.text),
	postalCode(UIElement.FIELD, "Postal Code", UIOptions.text),

	PAGE_2(UIElement.PAGE, "Page 2", null),
	SECTION_2_2(UIElement.SECTION, "Personal Information", null),
	birthYear(UIElement.FIELD, "Birth Year", UIOptions.text),
	birthMonth(UIElement.FIELD, "Month", UIOptions.text),
	birthDay(UIElement.FIELD, "Day", UIOptions.text),
	placeOfBirth(UIElement.FIELD, "Place of birth", UIOptions.text),
	SECTION_2_3(UIElement.SECTION, "Contact Information", null),
	homeNumber(UIElement.FIELD, "Home phone number", UIOptions.text),
	cellNumber(UIElement.FIELD, "Cell number", UIOptions.text),
	email(UIElement.FIELD, "Email", UIOptions.text),

	PAGE_3(UIElement.PAGE, "Page 3", null),
	SECTION_3_1(UIElement.SECTION, "Jamaat Information", null),
	WaqfNumber(UIElement.FIELD, "Waqfe Nau Ref. number", UIOptions.text),
	reconfirmationDone(UIElement.FIELD, "Re-Confirmation Form Done?", UIOptions.combo, "No", "Yes"),
	reconfirmation2ndDone(UIElement.FIELD, "Re-Confirmation Form Done after Education?", UIOptions.combo, "No", "Yes"),
	professionalFormDone(UIElement.FIELD, "Professional Particulars Form Done?", UIOptions.combo, "No", "Yes"),
	jamaat(UIElement.FIELD, "Local Jama'at of residence", UIOptions.text),
	officeBearer(UIElement.FIELD, "Are you an office bearer?", UIOptions.combo, "No", "Yes"),
	jamaatCode(UIElement.FIELD, "Assigned Jamaat Code", UIOptions.label),
	
	
	PAGE_4(UIElement.PAGE, "Page 4", null),
	SECTION_4_1(UIElement.SECTION, "Other Perticulars", null),
	father(UIElement.FIELD, "Father's Name", UIOptions.text),
	mother(UIElement.FIELD, "Mother's Name", UIOptions.text),
	GRAND_FATHER(UIElement.FIELD, "Grand Father's Name", UIOptions.text),
	SECTION_4_2(UIElement.SECTION, "Employment", null),
	jobType(UIElement.FIELD, "Type Of Employment", UIOptions.combo, "Service", "Personal Business"),
	job(UIElement.FIELD, "Job Title", UIOptions.text),
	jobContractLength(UIElement.FIELD, "If on contract, how long for?", UIOptions.text),
	
	PAGE_5(UIElement.PAGE, "Page 5", null),
	SECTION_5_1(UIElement.SECTION, "Education", null),
	finishedEducation(UIElement.FIELD, "Finished Education?", UIOptions.combo, "No", "Yes"),
	education(UIElement.FIELD, "Currect/Last degree/deploma", UIOptions.text),
	matricYear(UIElement.FIELD, "MATRIC/GCSE Year", UIOptions.text),
	matricGrade(UIElement.FIELD, "MATRIC/GCSE GRADE", UIOptions.text),
	faYear(UIElement.FIELD, "FA/F.Sc/A-level Year", UIOptions.text),
	faGrade(UIElement.FIELD, "FA/F.Sc/A-level GRADE", UIOptions.text),
	baYear(UIElement.FIELD, "BA/B.Sc Year", UIOptions.text),
	baGrade(UIElement.FIELD, "BA/B.Sc GRADE", UIOptions.text),
	maYear(UIElement.FIELD, "University Higher Education Year", UIOptions.text),
	maGrade(UIElement.FIELD, "University Higher Education GRADE", UIOptions.text),
	
	PAGE_6(UIElement.PAGE, "Page 6", null),
	SECTION_6_1(UIElement.SECTION, "Language", null),
	languageExpert(UIElement.FIELD, "Are you expert in any particular languages?", UIOptions.combo, "No", "Yes"),
	languageExpertWhat(UIElement.FIELD, "If yes then please specify languages.", UIOptions.text),
	languageUrduTranslate(UIElement.FIELD, "Are you able to translate from Urdu to any other language?", UIOptions.combo, "No", "Yes"),
	languageUrduTranslateWhat(UIElement.FIELD, "If yes then please specify languages.", UIOptions.text),
	languageTyping(UIElement.FIELD, "Are you able to type in any language?", UIOptions.combo, "No", "Yes"),
	languageTypingWhat(UIElement.FIELD, "If yes then please specify languages.", UIOptions.text),
	
	;

	private final UIElement uiElement;
	private final String caption;
	private final String key;
	private final UIOptions uiOption;
	private final String[] args;

	private Property(UIElement type, String caption, UIOptions uiOption,
			String... args) {
		this.uiElement = type;
		this.caption = caption;
		this.key = this.toString();
		this.uiOption = uiOption;
		this.args = args;
	}

	public void addToSchema(ObjectSchema objectSchema) {
		this.uiElement.addToSchema(this, objectSchema);
	}

	public UIElement getUiElement() {
		return uiElement;
	}

	public String getCaption() {
		return caption;
	}

	public String getKey() {
		return key;
	}

	public UIOptions getUiOption() {
		return uiOption;
	}

	public String[] getArgs() {
		return args;
	}

	public static List<Property> sortedByCaption() {
		
		List<Property> list = Arrays.asList(Property.values());
		
		Collections.sort(list, new Comparator<Property>() {

			@Override
			public int compare(Property p1, Property p2) {
				return p1.getCaption().compareTo(p2.getCaption());
			}
			
		});
		return list;

	}

}